<?php
namespace app\user\model;
use think\Model;
use think\model\concern\SoftDelete;

class Notice extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;
    protected $autoWriteTimestamp = true;
    protected $globalScope = ['shop_id'];
    public function scopeShop_id($query)
    {
        $query->where('shop_id', ShopId());
    }
    
    public function getDatetimeAttr($value)
    {
        return date('Y-m-d',$value);
    }
    public function setDatetimeAttr($value)
    {
        return strtotime($value);
    }
    public function getStatusAttr($value)
    {
        $name = ['0'=>'待办','1'=>'已完成'];
        return $name[$value];
    }
    public function customer()
    {
        return $this->belongsTo(Customer::class,'customer_id','id');
    }
    public function user()
    {
        return $this->belongsTo(User::class,'user_id','id');
    }
    
    
    
}